package com.ljw.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.io.File;

/**
 * @author ljw
 * @date 2020 3 22
 */
@Configuration
public class MyMvcConfig implements WebMvcConfigurer {

    //用于添加资源映射
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/images/**")
                .addResourceLocations("file:"+new File("").getAbsolutePath()+File.separator+
                        "uploads"+File.separator+"images"+File.separator);
    }

}
